<?php
    require('conn.cfg.php');
    require('functions.php');

    //notify order information
    $url = SUBMIT_ORDER_LINK;
//    $fields = array(
//        'infusionsoft_version' => '1.26.8.20',
//        'inf_form_xid' => '496356fede97b8201e638a70d163ae0f',        
//        'inf_form_name' => 'Capture order information',
//        'screenResolution'=> '1366x768',
//        'pluginList'=> 'Shockwave Flash,Shockwave Flash,Chrome Remote Desktop Viewer,Native Client,Chrome PDF Viewer,Internet Download Manager,Java Deployment Toolkit 6.0.270.7,Java(TM) Platform SE 6 U27,Microsoft® Windows Media Player Firefox Plugin,Foxit Reader Plugin for Mozilla,2007 Microsoft Office system,Microsoft Office 2010,Microsoft Office 2010,Windows Presentation Foundation,Octoshape Streaming Services,Octoshape Streaming Services,Google Update,Silverlight Plug-In,WPI Detector 1.4,VLC Multimedia Plug-in,TVU Web Player for FireFox',
//        'javaEnabled'=> 'true',
//        'inf_field_FirstName' => 'input1',
//        'inf_field_LastName' => 'input2',
//        'inf_field_Email' => 'input3@xxx.xx',
//        'inf_field_StreetAddress1' => 'input4 BMP',
//        'inf_field_StreetAddress2' => '',
//        'inf_field_City' => 'input5',
//        'inf_field_State' => 'CA',
//        'inf_field_PostalCode' => '12345',
//        'inf_field_Phone1' => '0919191911',
//        'inf_field_Country' => 'US',
//        'inf_field_Address2Street1' => 'input61',
//        'inf_field_Address2Street2' => 'input62',
//        'inf_field_City2' => 'input7',
//        'inf_field_State2' => 'CA',
//        'inf_field_PostalCode2' => '12312',
//        'inf_field_Phone2' => '091919219394',
//        'inf_field_Country2' => 'US',
//        'inf_custom_CreditCard' => 'VC',
//        'inf_custom_Creditcardnumber' => '411111111111111',
//        'inf_custom_ExpirationDate' => '0115'
//    );
        $infusionsoft_version = '1.26.8.20';
        $inf_form_xid = '496356fede97b8201e638a70d163ae0f';        
        $inf_form_name = 'Capture order $information';
        $screenResolution = '1366x768';
        $pluginList = 'Shockwave Flash,Shockwave Flash,Chrome Remote Desktop Viewer,Native Client,Chrome PDF Viewer,Internet Download Manager,Java Deployment Toolkit 6.0.270.7,Java(TM) Platform SE 6 U27,Microsoft® Windows Media Player Firefox Plugin,Foxit Reader Plugin for Mozilla,2007 Microsoft Office system,Microsoft Office 2010,Microsoft Office 2010,Windows Presentation Foundation,Octoshape Streaming Services,Octoshape Streaming Services,Google Update,Silverlight Plug-In,WPI Detector 1.4,VLC Multimedia Plug-in,TVU Web Player for FireFox';
        $javaEnabled = 'true';
        $inf_field_FirstName = 'input1';
        $inf_field_LastName = 'input2';
        $inf_field_Email = 'input3@xxx.xx';
        $inf_field_StreetAddress1 = 'input4 BMP';
        $inf_field_City = 'input5';
        $inf_field_State = 'CA';
        $inf_field_PostalCode = '12345';
        $inf_field_Phone1 = '0919191911';
        $inf_field_Address2Street1 = 'input61';
        $inf_field_City2 = 'input7';
        $inf_field_State2 = 'CA';
        $inf_field_PostalCode2 = '12312';
        $inf_field_Phone2 = '091919219394';
        $inf_custom_CreditCard = 'VC';
        $inf_custom_Creditcardnumber = '411111111111111';        
        $inf_custom_ExpirationDate = '0115';
        $inf_custom_freetrial = '';
        $inf_custom_Boxes = '2190';
        $inf_custom_Cases = '';
    
    $nvpreq = "inf_form_xid=".$inf_form_xid."&inf_form_name=".$inf_form_name."&infusionsoft_version=".$infusionsoft_version.
            "&screenResolution=".$screenResolution."&pluginList=".$pluginList."&javaEnabled=".$javaEnabled.
            "&inf_field_FirstName=".$inf_field_FirstName."&inf_field_LastName=".$inf_field_LastName."&inf_field_Email=".$inf_field_Email.
            "&inf_field_StreetAddress1=".$inf_field_StreetAddress1."&inf_field_City=".$inf_field_City.
            "&inf_field_State=".$inf_field_State."&inf_field_PostalCode=".$inf_field_PostalCode."&inf_field_Phone1=".$inf_field_Phone1.
            "&inf_field_Address2Street1=".$inf_field_Address2Street1."&inf_field_City2=".$inf_field_City2.
            "&inf_field_State2=".$inf_field_State2."&inf_field_PostalCode2=".$inf_field_PostalCode2."&inf_field_Phone2=".$inf_field_Phone2.
            "&inf_custom_CreditCard=".$inf_custom_CreditCard."&inf_custom_Creditcardnumber=".$inf_custom_Creditcardnumber."&inf_custom_ExpirationDate=".$inf_custom_ExpirationDate.
            "&inf_option_Freetrial=".$inf_custom_freetrial."&inf_option_Box=".$inf_custom_Boxes."&inf_option_Cases=".$inf_custom_Cases;
    
    $nvpreq = "inf_form_xid=496356fede97b8201e638a70d163ae0f&inf_form_name=Capture order information&infusionsoft_version=1.26.8.20&screenResolution=1280x1024&pluginList=Shockwave Flash,Google Update,Java(TM) Platform SE 6 U33,Java Deployment Toolkit 6.0.330.5,Foxit Reader Plugin for Mozilla,Silverlight Plug-In,Windows Presentation Foundation,Microsoft® DRM,Microsoft® DRM,Windows Media Player Plug-in Dynamic Link Library&javaEnabled=true&inf_field_FirstName=Quan&inf_field_LastName=PHAM&inf_field_Email=quantiensinh@gmail.com&inf_field_StreetAddress1=100 Bue str&inf_field_City=LA&inf_field_State=TX&inf_field_PostalCode=67890&inf_field_Phone1=013864844468&inf_field_Address2Street1=100 Bue str&inf_field_City2=LA&inf_field_State2=TX&inf_field_PostalCode2=67890&inf_field_Phone2=013864844468&inf_custom_CreditCard=disc&inf_custom_Creditcardnumber=4111111111111111&inf_custom_ExpirationDate=0118&inf_option_Freetrial=&inf_option_Box=2190&inf_option_Cases=2202";
             //notifyOrder($url, $nvpreq);
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_HEADER, 0);        
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    
    //execute post
    try {
        $result = curl_exec($ch);
        echo $result;
        if ($result['curl_error'])    throw new Exception($result['curl_error']);
        if ($result['http_code']!='200')    throw new Exception("HTTP Code = ".$result['http_code']);                
    } catch (Exception $e) {
        echo($e->getMessage());
    }

    //close connection
    curl_close($ch);    
?>
